<?php
namespace app\center\logic;

class DayAccountLogic extends BaseLogic {

    /**
     * 获取日记账统计查询条件
     * @param $department
     * @return array
     */
    public function get_search_wrat_maps($department){
        $maps = [];
        $maps[] = ['department','<>',''];

        if(!in_array('全部',$department)){
            $maps[] = ['department','in',$department];
        }
        return $maps;
    }

    /**
     * 获取日记账查询条件
     * @param $department
     * @param $start_time
     * @param $end_time
     * @return array
     */
    public function get_search_da_maps($department,$start_time,$end_time){
        $maps = [];
        if(!in_array('全部',$department)){
            $maps[] = ['department','in',$department];
        }

        if(!empty($start_time) && !empty($end_time)){
            $start_date = date('Y-m-d',strtotime($start_time));
            $end_date = date('Y-m-d',strtotime($end_time));
            $maps[] = ['now_date','between',[$start_date,$end_date]];
        }else{
            if(!empty($start_time)){
                $start_date = date('Y-m-d',strtotime($start_time));
                $maps[] = ['now_date','>=',$start_date];
            }
            if(!empty($end_time)){
                $end_date = date('Y-m-d',strtotime($end_time));
                $maps[] = ['now_date','<=',$end_date];
            }
        }
        return $maps;
    }
}